package com.wonders.frame.entity;


import com.wonders.frame.core.entity.EntityTemplate;

import javax.persistence.*;
import java.util.Set;

@SuppressWarnings("serial")
@Entity
@Table(name = "auth_role")
public class AuthRole extends EntityTemplate {


    @Column(name = "role_code")
    private String roleCode;

    @Column(name = "role_name")
    private String roleName;

    @ManyToMany(cascade = CascadeType.REMOVE,fetch = FetchType.EAGER)
    @JoinTable(name = "auth_role_permission",joinColumns = @JoinColumn(name="role_id",referencedColumnName = "id"),
            inverseJoinColumns = @JoinColumn(name = "permission_id",referencedColumnName = "id"))
    private Set<AuthPermission> pres;

    public String getRoleCode() {
        return roleCode;
    }

    public void setRoleCode(String roleCode) {
        this.roleCode = roleCode;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public Set<AuthPermission> getPres() {
        return pres;
    }
    @Transient
    public void setPres(Set<AuthPermission> pres) {
        this.pres = pres;
    }

    @Override
    public String toString() {
        return "AuthRole{" +
                "roleCode='" + roleCode + '\'' +
                ", roleName='" + roleName + '\'' +
                ", pres=" + pres +
                ", id='" + id + '\'' +
                ", removed=" + removed +
                '}';
    }
}
